package cn.village.service.impl;
import cn.village.dao.LabourContractMapper;
import cn.village.entity.LabourContract;
import cn.village.service.LabourContractService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class LabourContractServiceImpl implements LabourContractService {

    @Resource
    private LabourContractMapper labourContractMapper;

    public LabourContract getLabourContractById(String id)throws Exception{
        return labourContractMapper.getLabourContractById(id);
    }

    public List<LabourContract>	getLabourContractListByMap(Map<String,Object> param)throws Exception{
        return labourContractMapper.getLabourContractListByMap(param);
    }

    public Integer getLabourContractCountByMap(Map<String,Object> param)throws Exception{
        return labourContractMapper.getLabourContractCountByMap(param);
    }

    public Integer qdtxAddLabourContract(LabourContract labourContract)throws Exception{
            //labourContract.setCreatedTime(new Date());
            return labourContractMapper.insertLabourContract(labourContract);
    }

    public Integer qdtxModifyLabourContract(LabourContract labourContract)throws Exception{
        //labourContract.setUpdatedTime(new Date());
        return labourContractMapper.updateLabourContract(labourContract);
    }

    public Integer qdtxDeleteLabourContractById(String id)throws Exception{
        return labourContractMapper.deleteLabourContractById(id);
    }

    public Integer qdtxBatchDeleteLabourContract(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return labourContractMapper.batchDeleteLabourContract(param);
    }


}
